package com.fang.service.SecondService;

import com.fang.bean.UserInfo;
import com.fang.dao.UserInfoMapper;
import com.fang.service.IUserInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Resource
public class UserService implements IUserInfoService {
    @Resource
    UserInfoMapper userInfoMapper;
    UserInfo userInfo;

    @Override
    public boolean doLogined(UserInfo userInfo) {
        boolean isOk = false;
        List<UserInfo> list = userInfoMapper.selectList(userInfo);
        if(list != null && list.size()>0){
            isOk = true;
        }
        return isOk;
    }

    @Override
    public List<UserInfo> doSelect(UserInfo userInfo) {
        List<UserInfo> lst = userInfoMapper.queryListLike(userInfo);
        return lst;
    }

    @Override
    public int UpdateAndInsert(UserInfo userInfo) {
        int i = 0;
        if(userInfo.getUserid() != null && !userInfo.getUserid().equals("")){
            i = userInfoMapper.updateByPrimaryKeySelective(userInfo);
        }else{
           i = userInfoMapper.insertSelective(userInfo);
        }
        return i;
    }
}
